<template>
    <div class="toolbar" :class="showContent ? 'toolbar-out' : 'toolbar-wrap'">
        <div class="content"></div>
        <div class="but" @click="showContent = !showContent" :class="showContent ? 'pull-wrap' : 'list'"></div>
        <div class="toolist">
            <div class="pull" v-for="(item, index) in tools" :key="item.name"
                :class="{ 'cursor-active': cursorIcon == item.icon }" @mouseenter="cursorIcon = item.icon"
                @mouseleave="cursorIcon = ''">
                <i class="tab-ico" :class="item.icon"></i>
                <em class="tab-text">{{ item.name }}</em>
            </div>
        </div>
        <div class="back pull" :class="{ 'cursor-active': cursorIcon == 'top' }" @mouseenter="cursorIcon = 'top'"
            @mouseleave="cursorIcon = ''">
            <i class=" tab-ico top"></i>
            <em class="tab-text">顶部</em>
        </div>
    </div>
</template>

<script setup lang="ts" name="Toolbar">
import { ref } from 'vue';
let tools = ref([{
    name: '商品会员',
    icon: 'vip'
}, {
    name: '购物车',
    icon: 'cart'
}, {
    name: '我的关注',
    icon: 'follow'
}, {
    name: '我的足迹',
    icon: 'history'
}, {
    name: '我的消息',
    icon: 'message'
}, {
    name: '咨询',
    icon: 'jimi'
}]);
let cursorIcon = ref('');
let showContent = ref(false);

</script>

<style scoped lang="less">
.toolbar {
    position: fixed;
    z-index: 999;
    width: 300px;
    height: 100%;
    background-color: #7a6e6e;
    transition: right .3s ease-in-out 0s;

    &.toolbar-out {
        top: 0px;
        right: 0px;
    }

    &.toolbar-wrap {
        top: 0px;
        right: -294px;
    }

    .content {
        position: relative;
        left: 6px;
        width: 294px;
        background-color: bisque;
        height: 100%;
        z-index: 99;
    }

    .but {
        position: relative;
        width: 35px;
        height: 35px;
        line-height: 35px;
        text-align: center;
        margin-bottom: 1px;
        cursor: pointer;
        background-color: #7a6e6e;
        border-radius: 3px 0 0 3px;
        position: absolute;
        top: 0;
        /*right: -6px;*/
        left: -29px;

        &.list {
            background-image: url(./images/list.png);
            background-repeat: no-repeat;
            background-size: cover;
        }

        &.pull-wrap {
            background-image: url(./images/cross.png);
            background-repeat: no-repeat;
            background-size: cover;
        }
    }

    .toolist {
        position: absolute;
        top: 50%;
        left: -29px;
        width: 35px;
        margin-top: -80px;

        /*background-color: cadetblue;*/
        .pull {
            .vip {
                background-image: url(./images/toolbars.png);
                background-position: -88px -175px;
            }

            .cart {
                background-image: url(./images/toolbars.png);
                background-position: -50px 0;
            }

            .follow {
                background-image: url(./images/toolbars.png);
                background-position: -50px -50px;
            }

            .history {
                background-image: url(./images/toolbars.png);
                background-position: -50px -100px;
            }

            .message {
                background-image: url(./images/toolbars.png);
                background-position: -190px -150px;
            }

            .jimi {
                background-image: url(./images/toolbars.png);
                background-position: -50px -150px;
            }
        }
    }

    /* 鼠标悬浮样式 */
    .pull {
        position: relative;
        width: 35px;
        height: 35px;
        line-height: 35px;
        text-align: center;
        margin-bottom: 1px;
        cursor: pointer;
        background-color: #7a6e6e;
        border-radius: 3px 0 0 3px;
        z-index: 66;

        .tab-ico {
            display: inline-block;
            position: relative;
            /*background-image: url(img/toolbars.png);*/
            background-color: #7a6e6e;
            border-radius: 3px 0 0 3px;
            z-index: 2;
            width: 35px;
            height: 35px;
        }

        .tab-text {
            width: 62px;
            height: 35px;
            line-height: 35px;
            color: #fff;
            text-align: center;
            font-family: 微软雅黑;
            position: absolute;
            /*position: relative;*/
            z-index: 1;
            left: 35px;
            top: 0;
            background-color: #7a6e6e;
            border-radius: 3px 0 0 3px;
            font-style: normal;
            -webkit-transition: left .3s ease-in-out .1s;
            transition: left .3s ease-in-out .1s;
        }

        .top {
            background-image: url(./images/toolbars.png);
            background-position: -50px -250px;
        }

        &.back {
            position: absolute;
            bottom: 0;
            /*right: -6px;*/
            left: -29px;
            display: inline-block;
            background-image: url(./images/toolbars.png);

        }

        /* 鼠标悬浮样式 */
        &.cursor-active {
            .tab-text {
                left: -59px;
                background-color: #c81623;
            }

            .tab-ico {
                background-color: #c81623
            }
        }
    }

}
</style>